<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<html lang="en">
<head>
<%@include file="/WEB-INF/jsp/qsws/commons/head.jsp"%>
<link rel="stylesheet" type="text/css"
	href="resources/qsws/css/teaList.css">
<script src="resources/qsws/js/index.js" type="text/javascript"></script>
<script type="text/javascript">
	$(function() {
		var teacherListUrl = "qsws/teacherList";
		var sendedData = {
			"pageNumber" : 1,
			"pageSize" : 10
		};
		var loading = false;
		query(teacherListUrl, sendedData);
		$(window).scroll(
				function() {
					if (($(window).scrollTop() + $(window).height() > $(document).height() - 10) && !loading) {
						loading = true;
						sendedData.pageNumber = sendedData.pageNumber + 1;
						query(teacherListUrl, sendedData);
					}
				})

		function query(url, sendedData) {
			$.getJSON(url, sendedData, function(data) {
				loading = false;
				if (data == null) {
					alert('无任何数据，请检查接口是否正确');
					return;
				}
				var teachers = data.teacherList;
				if (teachers != null) {
					if (teachers.length == 0) {
						return;
					}
					var $a = $('ul a:first');
					for ( var i in teachers) {
						var $aClone = $a.clone();
						$aClone.attr('href',
								'qsws/toTeacherDetailPage?teacherId='
										+ teachers[i].id);
						$aClone.find('.teacherImg').attr(
								'src',
								(teachers[i].photo ? teachers[i].photo
										: 'resources/qsws/img/people1.jpg'));
						$aClone.find('.name').text(teachers[i].name);
						$aClone.find('.post').text(
								teachers[i].post ? teachers[i].post : '暂无');
						$aClone.show();
						$('ul').append($aClone);
					}
				}
			})
		}
	})
</script>
</head>
<body>
	<!-- 头部 -->
	<header>
		<a href="javascript:history.back();" class="back"></a>
		<h1>教师列表</h1>
	</header>
	<section>
		<div class="content">
			<ul>
				<a href="" style="display:none;"><li class="clearfix"><img
						class="teacherImg" alt="">
						<div>
							<p class="msg_name clearfix">
								<span class="name l"></span><span class="nums l">12学习</span>
							</p>
							<p class="msgs post"></p>
						</div></li>
				</a>
			</ul>
		</div>
	</section>
</body>
</html>